#pragma once

#include <memory>
#include <mutex>
#include "noncopyable.h"

namespace V_PDT
{
	template<typename T>
	class QSingleton : public noncopyable
	{
	protected:
		QSingleton() = default;
		~QSingleton() {};

	public:
		static std::shared_ptr<T> getInstance()
		{
			static std::once_flag s_flag;
			std::call_once(s_flag, [&]() {_instance = std::shared_ptr<T>(new T); });
			return _instance;
		}

	private:
		inline static std::shared_ptr<T> _instance = nullptr;
	};
}
